//
//  AppDelegate.m
//  01-UIViewHomeWork
//
//  Created by QC.L on 16/7/14.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "ViewController.h"
#import "SccondiewController.h"
#import "ThirdViewController.h"
#import "FourViewController.h"
#import "AccountView.h"
@interface AppDelegate ()<UITextFieldDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    _window = [[UIWindow alloc] init];
    _window.frame = [UIScreen mainScreen].bounds;
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    
    UITabBarController *tab = [UITabBarController alloc];
    FirstViewController *vc = [[FirstViewController alloc] init];
    UINavigationController *nc1 = [[UINavigationController alloc] init];
    UINavigationController *nc2 = [[UINavigationController alloc] init];
    UINavigationController *nc3 = [UINavigationController alloc];
    SccondiewController *svc = [[SccondiewController alloc] init];
    ThirdViewController *tvc = [[ThirdViewController alloc] init];
    tab.viewControllers = @[nc1,nc2,nc3];
    _window.rootViewController = tab;
    
    
    
    
#if 0
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:_window.bounds];
    [_window addSubview:imageView1];
    imageView1.image = [UIImage imageNamed:@"3"];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 300, 50, 50)];
    
    [_window addSubview:imageView];
    
//    imageView.image = [UIImage imageNamed:@"4"];
//
    
    UIImageView *imageViewOfLogo = [[UIImageView alloc] initWithFrame:CGRectMake((_window.frame.size.width - 100) / 2, 100, 100, 150)];
    [_window addSubview:imageViewOfLogo];
//
    imageViewOfLogo.image = [UIImage imageNamed:@"2"];
    
    
//    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 350, 50, 50)];
//    [_window addSubview:imageView2];
//    imageView2.image = [UIImage imageNamed:@"5"];
    
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(185, 600, 23, 19)];
    label.backgroundColor = [UIColor clearColor];
    label.text = @"or";
    label.textColor = [UIColor whiteColor];
    [_window addSubview:label];
    
    
//    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 300, _window.frame.size.width - 50, 50)];
//    textField.backgroundColor = [UIColor blackColor];
//    textField.alpha = 0.2;
//    textField.placeholder = @"请输入用户名";
//    textField.clearsOnBeginEditing = YES;
//    [_window addSubview:textField];
    
    
//    UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(50, 350, _window.frame.size.width - 50, 50)];
//    textField1.backgroundColor = [UIColor whiteColor];
//    textField1.placeholder = @"请输入密码";
//    textField1.clearsOnBeginEditing = YES;
//    [_window addSubview:textField1];
    
    
    
    UIButton *button1 = [[UIButton alloc] initWithFrame:CGRectMake(20, 430, _window.frame.size.width - 40, 40)];
    button1.backgroundColor = [UIColor greenColor];
    button1.alpha = 0.8;
    [button1 setTitle:@"登录" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(button1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [_window addSubview:button1];
    
    
    UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(20, 480, 80, 20)];
    button2.backgroundColor = [UIColor clearColor];
    [button2 setTitle:@"忘记密码" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(button2Clicked) forControlEvents:UIControlEventTouchUpInside];
    
    [_window addSubview:button2];
    
    
    UIButton *button3 = [[UIButton alloc] initWithFrame:CGRectMake((_window.frame.size.width - 120) / 2,500 , 120, 40)];
    [button3 setTitle:@"现在注册拉钩" forState:UIControlStateNormal];
    [button3 setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [button3 addTarget:self action:@selector(button3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [_window addSubview:button3];
    
    
    UIButton *button4 = [[UIButton alloc] initWithFrame:CGRectMake((_window.frame.size.width - 100 )/ 2, 550, 100, 30)];
    [button4 setTitle:@"随便逛逛" forState:UIControlStateNormal];
    [button4 addTarget:self action:@selector(button4Clicked) forControlEvents:UIControlEventTouchUpInside];
    [_window addSubview:button4];
    
    
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(12, 610, 150, 1)];
    lineView1.backgroundColor = [UIColor whiteColor];
    [_window addSubview:lineView1];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(220, 610, 150, 1)];
    lineView2.backgroundColor = [UIColor whiteColor];
    [_window addSubview:lineView2];
    
    AccountView *accountView = [[AccountView alloc] initWithFrame:CGRectMake(10,300, 350, 80)];
    
    accountView.layer.cornerRadius = 5;
    accountView.layer.masksToBounds = YES;
    [_window addSubview:accountView];
    
    
    
    
    
    
#endif

    
    
    
    
    
//    UIButton *imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    imageButton.frame = CGRectMake(20, 20, 200, 50);
//    imageButton.backgroundColor = [UIColor orangeColor];
//    [_window addSubview:imageButton];
//    
//    [imageButton setTitle:@"登录" forState:UIControlStateNormal];
//    
//    [imageButton setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
//    
//    
//    [imageButton setBackgroundImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
//
//    
//    imageButton.layer.cornerRadius = imageButton.frame.size.width ;
//    imageButton.layer.masksToBounds = NO;
    
    
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(140, 300, 100, 40)];
//    imageView.backgroundColor = [UIColor greenColor];
//    imageView.layer.cornerRadius = imageView.frame.size.height / 4;
//    imageView.layer.masksToBounds = YES;
//    [_window addSubview:imageView];
    
    
    
//    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
//    button2 .frame = CGRectMake(30, 50, 100, 100);
////    button2.backgroundColor = [UIColor redColor];
//    [button2 setTitle:@"注册" forState:UIControlStateNormal];
//    [button2 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
//    [button2 setImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];
//    [button2 setBackgroundImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
//    [button2 setBackgroundColor:[UIColor blueColor]];
    
    
//    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, 100, 100)];
//    label.backgroundColor = [UIColor redColor];
//    label.text = @"fdfadf";
//    label.lineBreakMode = NSLineBreakByWordWrapping;
//    label.shadowColor = [UIColor blackColor];
//    label.shadowOffset = CGSizeMake(-20, -2);
//    
//    [_window addSubview:label];
////    [_window addSubview:button2];
//    
//    
//    UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake(60, 100, 100, 100)];
//    field.backgroundColor = [UIColor redColor];
//    field.placeholder = @"dfghjd";
//    
//    [_window addSubview:field];
    
    
    
    return YES;
}

//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    ViewController *viewController1 = [[ViewController alloc] init];
//    viewController1.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
//    [_window.rootViewController presentViewController:viewController1 animated:YES completion:nil];
//}












//开始编辑前,判断能否编辑
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
//    处理点击return，需要进行的操作
//    可以回收键盘
    [textField endEditing:YES];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
